home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / CBASE102.ARJ / CBGETR.C < prev    next >
Text File  |  1991-09-23  |  2KB  |  90 lines

  1. /*    Copyright (c) 1989 Citadel    */
  2. /*       All Rights Reserved        */
  3.  
  4. /* #ident    "@(#)cbgetr.c    1.5 - 91/09/23" */
  5.  
  6. #include <ansi.h>
  7.  
  8. /* ansi headers */
  9. #include <errno.h>
  10.  
  11. /* library headers */
  12. #include <blkio.h>
  13. #include <lseq.h>
  14.  
  15. /* local headers */
  16. #include "cbase_.h"
  17.  
  18. /*man---------------------------------------------------------------------------
  19. NAME
  20.      cbgetr - get cbase record
  21.  
  22. SYNOPSIS
  23.      #include <cbase.h>
  24.  
  25.      int cbgetr(cbp, buf)
  26.      cbase_t *cbp;
  27.      void *buf;
  28.  
  29. DESCRIPTION
  30.      The cbgetr function reads the current record of cbase cbp into
  31.      buf.  buf must point to a storage area at least as large as the
  32.      record size for cbp.
  33.  
  34.      cbgetr will fail if one or more of the following is true:
  35.  
  36.      [EINVAL]       cbp is not a valid cbase pointer.
  37.      [EINVAL]       buf is the NULL pointer.
  38.      [CBELOCK]      cbp is not read locked.
  39.      [CBENOPEN]     cbp is not open.
  40.      [CBENREC]      The record cursor for cbp is null.
  41.  
  42. SEE ALSO
  43.      cbrcursor, cbrecsize, cbgetrf, cbputr.
  44.  
  45. DIAGNOSTICS
  46.      Upon successful completion, a value of 0 is returned.  Otherwise,
  47.      a value of -1 is returned, and errno set to indicate the error.
  48.  
  49. ------------------------------------------------------------------------------*/
  50. #ifdef AC_PROTO
  51. int cbgetr(cbase_t *cbp, void *buf)
  52. #else
  53. int cbgetr(cbp, buf)
  54. cbase_t *cbp;
  55. void *buf;
  56. #endif
  57. {
  58.     /* validate arguments */
  59.     if (!cb_valid(cbp) || buf == NULL) {
  60.         errno = EINVAL;
  61.         return -1;
  62.     }
  63.  
  64.     /* check if not open */
  65.     if (!(cbp->flags & CBOPEN)) {
  66.         errno = CBENOPEN;
  67.         return -1;
  68.     }
  69.  
  70.     /* check if not read locked */
  71.     if (!(cbp->flags & CBRDLCK)) {
  72.         errno = CBELOCK;
  73.         return -1;
  74.     }
  75.  
  76.     /* check if cursor is null */
  77.     if (lscursor(cbp->lsp) == NULL) {
  78.         errno = CBENREC;
  79.         return -1;
  80.     }
  81.  
  82.     /* read field */
  83.     if (lsgetr(cbp->lsp, buf) == -1) {
  84.         CBEPRINT;
  85.         return -1;
  86.     }
  87.  
  88.     return 0;
  89. }
  90.